<div class="reviews-settings">
  <div class="setting-item">
    <div class="setting-info">
      <div class="setting-label-row">
        <label class="setting-label">Download Public Reviews</label>
        <p-toggleswitch
          [(ngModel)]="publicReviewSettings.downloadEnabled"
          (onChange)="onPublicReviewsToggle($event.checked)">
        </p-toggleswitch>
      </div>
      <p class="setting-description">
        <i class="pi pi-info-circle"></i>
        Automatically download user reviews from enabled platforms (Amazon, Goodreads, Hardcover) when fetching book metadata. Reviews will be stored with your books for offline access.
      </p>
    </div>
  </div>

  @if (publicReviewSettings.downloadEnabled) {
    <div class="review-sources-section">
      <div class="sources-header">
        <h4 class="subsection-title">Review Sources</h4>
        <p class="subsection-description">Configure which platforms to download reviews from and set limits for each source.</p>
      </div>

      <div class="providers-list">
        @for (provider of publicReviewSettings.providers; track provider.provider) {
          <div class="provider-item">
            <div class="provider-setting">
              <div class="provider-label-row">
                <label class="provider-label">{{ provider.provider }}</label>
                <div class="provider-controls">
                  <p-toggleswitch
                    [(ngModel)]="provider.enabled"
                    (onChange)="onProviderToggle(provider.provider, $event.checked)">
                  </p-toggleswitch>
                  @if (provider.enabled) {
                    <div class="max-reviews-control">
                      <label class="max-reviews-label">Max Reviews:</label>
                      <input
                        type="number"
                        class="max-reviews-input"
                        min="1"
                        max="10"
                        [(ngModel)]="provider.maxReviews"
                        (blur)="onMaxReviewsChange(provider.provider, provider.maxReviews)"
                        title="Number of reviews to download (1-10)">
                    </div>
                  }
                </div>
              </div>
            </div>
          </div>
        }

        @if (publicReviewSettings.providers.length === 0) {
          <div class="no-providers-message">
            <i class="pi pi-exclamation-triangle"></i>
            <span>No review sources available. Please ensure metadata providers are configured in the Provider Settings section above.</span>
          </div>
        }
      </div>
    </div>
  }
</div>
